﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hi_Baidu.User.Serializable
{
    /// <summary>
    ///     用户可序列化数据类基类, 提供了该数据类的基本操作
    /// </summary>
    [Serializable]
    public abstract class Serializable : IMetaData, ISerializable
    {
        /// <summary>
        ///     用户可序列化数据类基类, 提供了该数据类的基本操作
        /// </summary>
        /// <param name="Key" type="string">
        ///     <para>
        ///         唯一标示
        ///     </para>
        /// </param>
        /// <param name="IsEncrypt" type="bool">
        ///     <para>
        ///         加密标示
        ///     </para>
        /// </param>
        public Serializable(String Key, bool IsEncrypt)
        {
            this.key = Key;
            this._IsEncrypt = IsEncrypt;
        }

        private String _Description;
        /// <summary>
        ///     描述
        /// </summary>
        public String Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        private String _Version;
        /// <summary>
        ///     版本
        /// </summary>
        public String Version
        {
            get { return _Version; }
            set { _Version = value; }
        }

        private bool _IsEncrypt;
        /// <summary>
        ///     加密标示
        /// </summary>
        public bool IsEncrypt
        {
            get { return _IsEncrypt; }
        }

        #region IMetaData 成员

        private String key;
        /// <summary>
        ///     唯一标示
        /// </summary>
        public string Key
        {
            get
            {
                return key;
            }
            set
            {
                key = value;
            }
        }

        #endregion

        #region ISerializable 成员

        /// <summary>
        ///     保存用户可序列化数据类
        /// </summary>
        /// <param name="FilePath" type="string">
        ///     <para>
        ///         保存文件路径
        ///     </para>
        /// </param>
        /// <returns>
        ///     返回false, 则表示保存失败
        /// </returns>
        public abstract bool Save(String FilePath);

        #endregion
    }
}
